/*
 * @Author: chichiksky
 * @Date: 2022-03-25 12:36:56
 * @LastEditTime: 2022-04-02 17:35:20
 * @LastEditors: your name
 * @Description:
 * @FilePath: \web\src\components\class\courseItem\index.jsx
 */

import "./index.css";
import _date from "../../../assets/common/date";
import React from "react";
import { useNavigate } from "react-router-dom";
import Cookie from "../../../assets/common/cookie";
const CourseItem = (props) => {

  const navigate = useNavigate()
  const {item, type} = props;
  const detail = Number(type) === 2 ? 'jobSettings': 'homework';
  return (
    <div className="item">
      <img
        src={item.url}
        alt="图片无法显示"
        onClick={() => {navigate(`/coursePage/${item._id}/${detail}`);Cookie.set('class',JSON.stringify(item._class))}}
      />
      <div>
        <h3>{item.name}</h3>
        <p>{item.teacher_name}</p>
        <p>{item.time && item.time.split('~').map(e => _date.changeTimeFormat(e)).join('~')}</p>
      </div>
    </div>
  );
};
export default CourseItem;
